package com.xysd.express.util;

import android.view.View;

/**防连击工具类
 * Created by donghui on 2017/8/4.
 *
 */

public class DoubleClickUtil {
    private static long mLastClick;

    public static boolean isDoubleClick(long milliseconds){
        //大于milliseconds方可通过
        if (System.currentTimeMillis() - mLastClick <= milliseconds){
            return true;
        }
        mLastClick = System.currentTimeMillis();
        return false;
    }


    public static void shakeClick(final View v, long milliseconds) {
        v.setClickable(false);
        v.postDelayed(new Runnable(){
            @Override
            public void run() {
                v.setClickable(true);
            }
        }, milliseconds);
    }
}
